<!DOCTYPE html>
<html>
 
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>flv.js demo</title>
 
    <style>
        .mainContainer {
            display: block;
            width: 700px;
            margin-left: auto;
            margin-right: auto;
        }
 
        .urlInput {
            display: block;
            width: 100%;
            margin-left: auto;
            margin-right: auto;
            margin-top: 8px;
            margin-bottom: 8px;
        }
 
        .centeredVideo {
            display: block;
            width: 100%;
            height: 400px;
            margin-left: auto;
            margin-right: auto;
            margin-bottom: auto;
        }
 
        .controls {
            display: block;
            width: 100%;
            text-align: left;
            margin-left: auto;
            margin-right: auto;
        }
    </style>
</head>
 
<body>
    
    <div class="mainContainer">
    
    
<!--  <video  width="500px" height="300px" autoplay="autoplay">
    <source src="http://v2.91p48.com/mp43/377253.mp4?secure=BvGX2Po25vik3SSQqcWhQw==,1592667933&f=7d8fMTgpJoQg4/cQWy7d8Gy08+puRLnb95h0SmO5LOoRtRxdDEGQ2n/JCFY" type="video/mp4">
</video>  -->
<!--  <video  width="500px" height="300px" autoplay="autoplay">
    <source src="../2.mp4" type="video/mp4">
</video> 
 -->
<!--  -->
<video controls="" autoplay="" name="media">
<source src="/video?path=big_buck_bunny.mp4" type="video/mp4" >
</video>

<!-- <video controls="" autoplay="" name="media">
<source src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4">
</video> -->

        <input name="urlinput" class="urlInput" type="text" value="/video?path=big_buck_bunny.mp4"/>
        <video name="videoElement" class="centeredVideo"  controls="" autoplay="" name="media" autoplay ></video>
        <br>
        <div class="controls">
            <button οnclick="flv_load()">Load</button>
            <button οnclick="flv_start()">Start</button>
            <button οnclick="flv_pause()">Pause</button>
            <button οnclick="flv_destroy()">Destroy</button>
            <input style="width:100px" type="text" name="seekpoint"/>
            <button οnclick="flv_seekto()">SeekTo</button>
        </div>
    </div>
 
 
    <script src="/static/lib/flv/flv.min.js" type="text/javascript" ></script>
    <script>
        function flv_load() {
            console.log('isSupported: ' + flvjs.isSupported());
            var urlinput = document.getElementsByName('urlinput')[0];
            var xhr = new XMLHttpRequest();
            xhr.open('GET', urlinput.value, true);
            xhr.onload = function (e) {
                var player;
                var element = document.getElementsByName('videoElement')[0];
                if (typeof player !== "undefined") {
                    if (player != null) {
                        player.unload();
                        player.detachMediaElement();
                        player.destroy();
                        player = null;
                    }
                }
              
                player = flvjs.createPlayer({
                    type: 'mp4',
                    url: urlinput.value
                });
                player.attachMediaElement(element);
                player.load();
            }
            xhr.send();
        }
 
        function flv_start() {
        	 console.log('flv_start: ');
            player.play();
        }
 
        function flv_pause() {
        	 console.log('flv_pause: ');
            player.pause();
        }
 
        function flv_destroy() {
        	 console.log('flv_destroy: ');
            player.pause();
            player.unload();
            player.detachMediaElement();
            player.destroy();
            player = null;
        }
 
        function flv_seekto() {
        	 console.log('flv_seekto: ');
            var input = document.getElementsByName('seekpoint')[0];
            player.currentTime = parseFloat(input.value);
        }
 
        function getUrlParam(key, defaultValue) {
            var pageUrl = window.location.search.substring(1);
            var pairs = pageUrl.split('&');
            for (var i = 0; i < pairs.length; i++) {
                var keyAndValue = pairs[i].split('=');
                if (keyAndValue[0] === key) {
                    return keyAndValue[1];
                }
            }
            return defaultValue;
        }
 
        var urlInputBox = document.getElementsByName('urlinput')[0];
        var url = decodeURIComponent(getUrlParam('src', urlInputBox.value));
        urlInputBox.value = url;
        
        document.addEventListener('DOMContentLoaded', function () {
            flv_load();
        });
    </script>
    
</body>
 
</html>
